calcAllStockStatus <- function(tblname="STS", method="") {
  con <- connectToVadb()
  groupStockStatus("INDEX_MAJORS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "INDEX_MAJORS", sep="_"), verbose=TRUE)
  groupStockStatus("INDEX_MAJORS_OOS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "INDEX_MAJORS_OOS", sep="_"), verbose=TRUE)
  
  groupStockStatus("DJI_STOCKS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "DJI_STOCKS", sep="_"), verbose=TRUE)
  groupStockStatus("DJI_STOCKS_OOS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "DJI_STOCKS_OOS", sep="_"), verbose=TRUE)

  groupStockStatus("SMALL_CAPS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "SMALL_CAPS", sep="_"), verbose=TRUE)
  groupStockStatus("SMALL_CAPS_OOS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "SMALL_CAPS_OOS", sep="_"), verbose=TRUE)
  
  groupStockStatus("PM_STOCKS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "PM_STOCKS", sep="_"), verbose=TRUE)
  groupStockStatus("PM_STOCKS_OOS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "PM_STOCKS_OOS", sep="_"), verbose=TRUE)
  
  groupStockStatus("TECH_STOCKS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "TECH_STOCKS", sep="_"), verbose=TRUE)
  groupStockStatus("TECH_STOCKS_OOS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "TECH_STOCKS_OOS", sep="_"), verbose=TRUE)
  
  groupStockStatus("STEEL_STOCKS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "TECH_STOCKS", sep="_"), verbose=TRUE)
  
  groupStockStatus("AUTO_STOCKS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "TECH_STOCKS", sep="_"), verbose=TRUE)
  
  groupStockStatus("DRUGS", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "TECH_STOCKS", sep="_"), verbose=TRUE)
  
  groupStockStatus("BEVERAGES", tblname=tblname, verbose=TRUE, method=method)
  calcSSCombinations(con, paste(tblname, method, "TECH_STOCKS", sep="_"), verbose=TRUE)
  
  disconnectFromVadb(con)
}

calcAllStockStatus1 <- function() {
  tblname <- "STS"
  groups <- c("DRUGS", "BEVERAGES")
  methods <- c("ADX", "DONCHIAN", "GAP", "MARUBOZU_1_3", "MARUBOZU", "STOMACH", "THREE")
  con <- connectToVadb()  
  for (group in groups) {
    for (method in methods) {
      groupStockStatus(group, tblname=tblname, verbose=TRUE, method=method)
      calcSSCombinations(con, paste(tblname, method, group, sep="_"), verbose=TRUE)
    }
  }
  disconnectFromVadb(con)
}
